﻿Public Class KundenverwaltungAdapter
    Inherits StammdatenverwaltungAdapter(Of frmKundenverwaltung, KundeverwaltungListener, Kunde)

    Public Sub New()
        MyBase.New(New frmKundenverwaltung)
        setListView(form.lsvKunden)
        setDeleteButton(form.btnDelete)
        setEditButton(form.btnBearbeiten)
        setSaveButton(form.btnSave)
        Me.addColumn("Firma", "firmenname")
        Context.KUNDE_PROJEKT_TASK_SERVICE.getObservable.addListener(Me)
    End Sub

    ' KundeChange:
    Public Overrides Sub onKundenChanged(ByRef kunden As List(Of Kunde))
        MyBase.onKundenChanged(kunden)
        setData(kunden)
    End Sub

    Protected Overrides Function getFormEntity(ByRef editEntity As Kunde) As Kunde
        Dim kunde As Kunde = editEntity
        If kunde Is Nothing Then
            kunde = New Kunde()
        End If
        kunde.firmenname = form.txtKundeErfassen.Text
        Return kunde
    End Function

    Protected Overrides Sub setFormEntity(ByRef entity As Kunde)
        form.txtKundeErfassen.Text = entity.firmenname
    End Sub

    Protected Overrides Sub clearForm()
        form.txtKundeErfassen.Text = ""
    End Sub
End Class
